package com.eqdd.yiqidian.utils;

import com.eqdd.yiqidian.bean.FriendBean;

import java.util.Comparator;

/**
 * Created by lvzhihao on 17-4-10.
 */

public class PinyinComparator implements Comparator {

    @Override
    public int compare(Object arg0, Object arg1) {
        // 按照名字排序
        FriendBean user0 = (FriendBean) arg0;
        FriendBean user1 = (FriendBean) arg1;
        String catalog0 = "";
        String catalog1 = "";

        if (user0 != null && user0.getPname() != null
                && user0.getPname().length() > 1)
            catalog0 = PinYinUtil.getPinyin(user0.getPname())
                    .substring(0, 1);

        if (user1 != null && user1.getPname() != null
                && user1.getPname().length() > 1)
            catalog1 = PinYinUtil.getPinyin(user0.getPname())
                    .substring(0, 1);
        int flag = catalog0.compareTo(catalog1);
        return flag;

    }

}
